"""
Coversion app. v2.0
By Kungen (mafaer@gmail.com)
    14/09/09
"""

def Menu():
    print '\n';
    print 'Conversion Menu:';

    print '     (1)     Convert Celsius to Fahrenheit';
    print '     (2)     Convert Fahrenheit to Celsius';
    
    print '     (3)     Convert Kilometers to Miles';
    print '     (4)     Convert Miles to Kilometers';
    print '     (5)     Convert Meters to Feet';
    print '     (6)     Convert Feet to Meters';
    print '     (7)     Convert Centimeters to Inches';
    print '     (8)     Convert Inches to Centimeters';
    
    print '     (9)     Convert Kilos to Pounds';
    print '     (10)    Convert Pounds to Kilos';
    
    print '     (11)    Convert Liters to US Gallons';
    print '     (12)    Convert US Gallons to Liters';
    print '     (13)    Convert Centiliters to US Ounces';
    print '     (14)    Convert US Ounces to Centiliters';

    print '     (15)    Convert Kilometers/h to Miles/h';
    print '     (16)    Convert Miles/h to Kilometers/h';
    print '     (17)    Convert Kilometers/h to Knots';
    print '     (18)    Convert Knots to Kilometers/h';


def Option():

    choice = input('\n Enter choice number --> ')

    if (choice == 1):
        C2F();
    elif (choice == 2):
        F2C();
        
    elif (choice == 3):
        Km2Mi();
    elif (choice == 4):
        Mi2Km();
    elif (choice == 5):
        M2Ft();
    elif (choice == 6):
        Ft2M();
    elif (choice == 7):
        Cm2In();
    elif (choice == 8):
        In2Cm();
        
    elif (choice == 9):
        Kg2Lb();
    elif (choice == 10):
        Lb2Kg();

    elif (choice == 11):
        L2Gal();
    elif (choice == 12):
        Gal2L();
    elif (choice == 13):
        Cl2Oz();
    elif (choice == 14):
        Oz2Cl();

    elif (choice == 15):
        Kmh2Mph();
    elif (choice == 16):
        Mph2Kmh();
    elif (choice == 17):
        Kmh2Kt();
    elif (choice == 18):
        Kt2Kmh();

    else:
        print '\n\t', repr(choice), 'is not an alternative.';
        Option();


def C2F():  #1
    C   = input('\n Enter degrees in Celsius --> ');
    F   = (9.0 / 5.0) * C + 32;
    print '\n\t', C, 'Celsius equals to ', F, 'Fahrenheit.';
    Restart();

def F2C():  #2
    F   = input ('\n Enter degrees in Fahrenheit --> ');
    C   = (5.0 / 9.0) * (F - 32);
    print '\n\t', F, 'Fahrenheit equals to ', C, 'Celsius.';
    Restart();

def Km2Mi():  #3
    Km   = input('Enter number of Kilometers --> ');
    Mi   = Km * 0.621371192;
    print '\n\t', Km, 'Kilometers equals to ', Mi, 'Miles.';
    Restart();

def Mi2Km():  #4
    Mi   = input('Enter number of Miles --> ');
    Km   = Mi * 1.609344;
    print '\n\t', Mi, 'Miles equals to ', Km, 'Kilometers.';
    Restart();
    
def M2Ft():  #5
    M   = input('Enter number of Meters --> ');
    F   = M * 3.2808399;
    print '\n\t', M, 'Meters equals to ', F, 'Feet.';
    Restart();

def Ft2M():  #6
    F   = input('Enter number of Feet --> ');
    M   = F * 0.3048;
    print '\n\t', F, 'Feet equals to ', M, 'Meters.';
    Restart();

def Cm2In():  #7
    Cm  = input('Enter number of Centimeters --> ');
    In  = Cm * 0.393700787;
    print '\n\t', Cm, 'Centimeters equals to ', In, 'Inches.';
    Restart();

def In2Cm():  #8
    In  = input('Enter number of Inches --> ');
    Cm  = In * 2.54;
    print '\n\t', In, 'Inches equals to ', Cm, 'Centimeters.';
    Restart();

def Kg2Lb():  #9
    Kg  = input('Enter number of Kilos --> ');
    Lb  = Kg * 2.20462262;
    print '\n\t', Kg, 'Kilos equals to ', Lb, 'Pounds.';
    Restart();

def Lb2Kg():  #10
    Lb  = input('Enter number of Pounds --> ');
    Kg  = Lb * 0.45359237;
    print '\n\t', Lb, 'Pounds equals to ', Kg, 'Kilos.';
    Restart();

def L2Gal():  #11
    L  = input('Enter number of Liters --> ');
    Gal  = L * 0.264172052;
    print '\n\t', L, 'Liters equals to ', Gal, 'US Gallons.';
    Restart();

def Gal2L():  #12
    Gal  = input('Enter number of Gallons --> ');
    L  = Gal * 3.78541178;
    print '\n\t', Gal, 'US Gallons equals to ', L, 'Liters.';
    Restart();

def Cl2Oz():  #13
    Cl  = input('Enter number of Centiliters --> ');
    Oz  = Cl * 0.338140227;
    print '\n\t', Cl, 'Centiliters equals to ', Oz, 'US Ounces.';
    Restart();

def Oz2Cl():  #14
    Oz  = input('Enter number of US Ounces --> ');
    Cl  = Oz * 2.95735296;
    print '\n\t', Oz, 'US Ounces equals to ', Cl, 'Centliters.';
    Restart();
    
def Kmh2Mph():  #15
    Kmh  = input('Enter number of Kilometers/h --> ');
    Mph  = Kmh * 0.621;
    print '\n\t', Kmh, 'Kilometers/h equals to ', Mph, 'Miles/h.';
    Restart();

def Mph2Kmh():  #16
    Mph  = input('Enter number of Miles/h --> ');
    Kmh  = Mph * 1.609;
    print '\n\t', Mph, 'Miles/h equals to ', Kmh, 'Kilometers/h.';
    Restart();
    
def Kmh2Kt():  #17
    Kmh  = input('Enter number of Kilometers/h --> ');
    Kt  = Kmh * 0.539956803;
    print '\n\t', Kmh, 'Kilometers/h equals to ', Kt, 'Knots.';
    Restart();

def Kt2Kmh():  #18
    Kt  = input('Enter number of Knots --> ');
    Kmh  = Kt * 1.852;
    print '\n\t', Kt, 'Knots equals to ', Kmh, 'Kilometers/h.';
    Restart();


    

def Restart():
    print '\n';
    print '(1)  New conversion';
    print '(2)  Conversion Menu + New conversion';
    print '(3)  Exit';
    choice2 = input('\n Enter choice number --> ');
    if choice2 == 1:
        Option();
    elif choice2 == 2:
        Run();
    elif choice2 == 3:
        raw_input('\n\t Press<enter>');
        
def Run():
    Menu();
    Option();
        

print 'Conversion app. v2.0 \n by Kungen @ mafaer@gmail.com';
Run();
